package org.kjk.mail;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractController;

public class GMailContentController extends AbstractController {
	private GMail gmail;
	
	@Override
	protected ModelAndView handleRequestInternal(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		String index = request.getParameter("index");
		if (index == null || index.length() == 0) {
			index = "0";
		}
		System.out.println("index : " + index);
		@SuppressWarnings("unchecked")
		List<GMailDTO> mail = (List<GMailDTO>) request.getSession().getAttribute("mail");
		return new ModelAndView("mail/receivemail.jsp", "mail", mail.get(Integer.parseInt(index)));
	}

	public void setGmail(GMail gmail) {
		this.gmail = gmail;
	}

}
